Column

Scatter plot of Minimum temperature vs Maximum temperature across three US cities

Column

Boxplot of minimum temperatures across three US cities

Barplot of total precipitation across three US cities

---
title: "Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source: embed
---

```{r setup, echo = FALSE}
library(flexdashboard)

library(tidyverse)
library(p8105.datasets)
library(plotly)
library(dplyr)
library(rnoaa)

knitr::opts_chunk$set(
	echo = TRUE,
	warning = FALSE,
	fig.width = 8, 
  fig.height = 6,
  out.width = "90%"
)

theme_set(theme_minimal() + theme(legend.position = "bottom"))

options(
  ggplot2.continuous.colour = "viridis",
  ggplot2.continuous.fill = "viridis"
)

scale_colour_discrete = scale_colour_viridis_d
scale_fill_discrete = scale_fill_viridis_d
```

```{r echo = FALSE}
weather_df = 
  rnoaa::meteo_pull_monitors(
    c("USW00094728", "USW00022534", "USS0023B17S"),
    var = c("PRCP", "TMIN", "TMAX"), 
    date_min = "2021-01-01",
    date_max = "2022-12-31") |>
  mutate(
    name = case_match(
      id, 
      "USW00094728" ~ "CentralPark_NY", 
      "USW00022534" ~ "Molokai_HI",
      "USS0023B17S" ~ "Waterhole_WA"),
    tmin = tmin / 10,
    tmax = tmax / 10) |>
  select(name, id, everything())
```




Column {data-width=650}
-----------------------------------------------------------------------

### Scatter plot of Minimum temperature vs Maximum temperature across three US cities

```{r echo = FALSE}
weather_df |>
  plot_ly(
    x = ~tmin, y = ~tmax, type = "scatter", mode = "markers",
    color = ~name, alpha = 0.5)
```

Column {data-width=350}
-----------------------------------------------------------------------

### Boxplot of minimum temperatures across three US cities

```{r echo = FALSE}
  weather_df |>
  plot_ly(y = ~tmin, color = ~name, type = "box", colors = "viridis") 
```

### Barplot of total precipitation across three US cities 

```{r echo = FALSE}
  weather_df |>
  plot_ly(x = ~name, y = ~prcp, color = ~name, type = "bar", colors = "viridis")
```